package com.bb.blog.activiti.impl;

import com.bb.blog.activiti.service.TaskQueryService;
import com.bb.blog.web.exception.ServerException;
import lombok.RequiredArgsConstructor;
import org.activiti.engine.TaskService;
import org.activiti.engine.task.Task;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor
public class TaskQueryServiceImpl implements TaskQueryService {
    private TaskService taskService;

    @Override
    public Task queryTaskById(String taskId) {
        Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
        if (task == null) {
            throw new ServerException(400, "任务不存在");
        }
        return task;
    }
}
